#include <cmath>
#include <iostream>
#include <string>

bool is_prime(int n) {
    if (n < 2) {
        return false;
    }
    for (int i = 2; i <= static_cast<int>(std::sqrt(n)) + 1; i++) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

int nearest_prime_number(std::string num) {
    if (std::all_of(num.begin(), num.end(), ::isdigit) && num.length() == 3) {
        int n = std::stoi(num);
        while (true) {
            if (is_prime(n)) {
                return n;
            }
            n++;
        }
    } else {
        return -1;
    }
}

int main() {
    std::string input;
    std::getline(std::cin, input);
    std::string number;
    std::string words[] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};
    for (const auto& word : words) {
        size_t pos = input.find(word);
        while (pos != std::string::npos) {
            number += std::to_string(static_cast<int>(word - words[0]));
            input.erase(pos, word.length());
            pos = input.find(word);
        }
    }
    std::cout << nearest_prime_number(number) << std::endl;
    return 0;
}

